home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-03-15 | 8.9 KB | 270 lines | [TEXT/KAHL] |
- THINK C 4.0 ERRATA
- ==================
- Copyright © 1990 Symantec Corporation. All Rights Reserved.
-
- This document corrects several known errors in the documentation for THINK C
- 4.0. It has three parts:
-
- • QUESTIONS AND ANSWERS answers several questions users asked about
- the Standard Library Reference.
-
- • CORRECTIONS corrects typos and other errors in the THINK C 4.0
- documentation, chapter by chapter.
-
- • NEW FUNCTION DESCRIPTIONS documents some functions that were left
- out of the Standard Library Reference: cecho2printer(), gets(),
- sin(), sinh(), and sqrt().
-
- QUESTIONS AND ANSWERS
- =====================
- This section several questions users asked about the Standard Library
- Reference. The questions are about using the console package, reading from
- stdio, and reading to and writing from text files.
-
- • WHERE IS THE CONSOLE LIBRARY?
-
- There is no console library. That’s an error in the manual. All the functions
- described in Chapter 4 of the Standard Libraries Reference are in the ANSI
- library. To use these functions in your program, add the ANSI library in your
- project and #include console.h in your files. You do not need to add a console
- library.
-
- • HOW DO I USE THE CONSOLE FUNCTIONS CSETMODE() AND CGOTOXY() WITH A CONSOLE
- WINDOW?
-
- Before calling csetmode() or cgotoxy(), call printf("\n"). The functions
- csetmode() and cgotoxy() use the file pointer stdout but don’t initialize it.
- The function printf() initializes stdout (and stdin and stderr, too) to be the
- console window.
-
- • HOW DO I GENERATE THE END-OF-FILE (EOF) CHARACTER?
-
- To generate the end-of-file character when a program is reading from stdio,
- press Control-D.
-
- • WHY DON’T I GET WHAT I EXPECT WHEN I READ FROM OR WRITE TO TEXT FILES?
-
- When you write to a text file, '\r' (a carriage return or 0x0D) is converted
- to '\n' (a line feed or 0x0A). When you read from a text file, '\n' is
- converted to '\r'.
-
- NOTE: This conversion isn’t performed with binary files. To open a
- file as a binary file, use the function fopen() and append the
- character 'b' to the argument type.
-
- For example, this statement:
-
- fputc('\r', f);
-
- writes the character '\n' to the file f.
-
- If the file f contains "hello\n", this statement:
-
- fgets(s, 80, f);
-
- puts the string "hello\r" into the variable s.
-
- CORRECTIONS
- ===========
- This section corrects typos, omissions, and other errors in the THINK C 4.0
- documentation, chapter by chapter.
-
- User’s Manual, Chapter 53, “CWindow”
- ------------------------------------
-
- • On page 394, the declaration for IWindow() should be:
-
- void IWindow( short WINDid, Boolean aFloating,
- CDesktop *anEnclosure,
- CDirector *aSupervisor );
-
- Note that anEnclosure is a pointer to a CDesktop, not a pointer to a
- CView.
-
- Standard Libraries Reference, Chapter 2, “ANSI Header Files”
- ------------------------------------------------------------
-
- • In the list of macros for <float.h> on page 7, the values of DBL_MIN and
- LDBL_MIN should be 1.0E-4926, not 1.0E-4915.
-
- • In the list of macros for <stdlib.h> on page 19, the value of RAND_MAX
- should be 32767, not 3267.
-
- • In the list of functions for <string.h> on page 20 , strcfrm() should
- be strxfrm().
-
- • In the list of types in <time.h> on page 21 , tm is not described. It is
- a structure for broken-down time and is defined like this:
-
- struct tm {
- int tm_sec; /* seconds after the minute */
- int tm_min; /* minutes after the hour */
- int tm_hour; /* hours since midnight */
- int tm_mday; /* day of the month */
- int tm_mon; /* months since January */
- int tm_year; /* years since 1900 */
- int tm_wday; /* days since Sunday */
- int tm_yday; /* days since January 1 */
- int tm_isdst; /* Daylight Saving Time flag */
- };
-
- Standard Libraries Reference, Chapter 3, “ANSI”
- -----------------------------------------------
-
- • These functions aren’t documented: gets(), sin(), sinh(), and sqrt()
- They’re described later in this document
-
- • The functions __getc() and __putc() are the same as getc() and putc(),
- except __getc() and __putc() don’t do any error-checking. For more robust
- code, use getc() and putc() whenever possible. The functions __getc()
- and __putc() are THINK C extensions to the ANSI standard.
-
- • To use abs() on page 29 or labs() on page 82, #include stdlib.h, not
- math.h.
-
- • To use strlen() on page 134, #include string.h, not strings.h.
-
- Standard Libraries Reference, Chapter 4, “console”
- --------------------------------------------------
-
- • There is no console library. All the functions in this chapter are in the
- ANSI library.
-
- • The function cecho2printer() isn’t documented. It’s described later in
- this document.
-
- • Despite what the manual says on page 166, ccommand() cannot redirect
- stderr.
-
- • On page 168, C_BREAK should be C_CBREAK.
-
- Standard Libraries Reference, Chapter 5, “unix”
- -----------------------------------------------
-
- • To use open() on page 196, you need to #include fcntl.h in addition to
- unix.h.
-
-
- NEW METHODS
- ===========
- New methods were added to three classes in the Core Classes of the
- THINK Class Library.
-
- CError
- ------
- void MissingResources()
- If gError gets a SevereMacError message, and it can’t find the
- STR resource to report a “resource not found” error, SevereMacError()
- sends a MissingResources() message to gError. This method displays
- an error alert without using any resources.
-
- CPanorama
- ---------
- void DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent)
- This method supports the Home, End, Page Up, and Page Down keys on the
- extended keyboard for all panoramas. The Home key is equivalent to
- scrolling to the top of the panorama; the End key is equivalent to
- scrolling to the bottom of the panorama. The Page Up and Page Down keys
- are equivalent to clicking on the page up and page down regions of the
- vertical scroll bar of the panorama.
-
- CPicture
- --------
- void Dispose()
- This method disposes of the picture stored in the macPicture
- instance variable.
-
-
- NEW FUNCTION DESCRIPTIONS
- =========================
- This section includes documentation for these functions, which were left out
- of the Standard Libraries Reference:
-
- • cecho2printer(), from Chapter 4, “console”
- • gets(), from Chapter 3, “ANSI”
- • sin(), from Chapter 3, “ANSI”
- • sinh(), from Chapter 3, “ANSI”
- • sqrt(), from Chapter 3, “ANSI”
-
- ______________________________________________________________________________
-
- cecho2printer
-
- LIBRARY ANSI
-
- SYNTAX #include <console.h>
- void cecho2printer(FILE *fp);
-
- DESCRIPTION Echo output to the printer selected in the Chooser desk
- accessory.
-
- cecho2printer() writes to the printer any complete lines
- that the program writes to the console fp.
-
- ______________________________________________________________________________
-
- gets
-
- LIBRARY ANSI
-
- SYNTAX #include <stdio.h>
- char *gets(char *s);
-
- DESCRIPTION gets() reads the next line from stdin into the array s.
- gets() stops reading after it encounters a new-line or EOF
- character, replaces the new-line or EOF in s with a NULL
- character, and returns successful.
-
- RETURNS s, if successful.
-
- NULL, if failure. If it encounters an EOF and has not read
- any characters, it doesn’t change the contents of s and
- sets the EOF error flag in the file descriptor. If a read
- error occurs, the contents of s are indeterminate.
-
- ______________________________________________________________________________
-
- sin
-
- LIBRARY ANSI
-
- SYNTAX #include <math.h>
- double sin(double x);
-
- DESCRIPTION sin() computes the sine of the argument x.
-
- RETURNS sin x, in radians.
-
- ______________________________________________________________________________
-
- sinh
-
- LIBRARY ANSI
-
- SYNTAX #include <math.h>
- double sinh(double x);
-
- DESCRIPTION sinh() computes the hyperbolic sine of the argument x.
-
- RETURNS sinh x, in radians, if successful.
-
- Infinity, if x greater than HUGE_VAL. It also sets errno
- to ERANGE.
-
- ______________________________________________________________________________
-
- sqrt
-
- LIBRARY ANSI
-
- SYNTAX #include <math.h>
- double sqrt(double x);
-
- DESCRIPTION sqrt() computes the square root of the argument x.
-
- RETURNS The square root of x, if successful,
-
- 0, if x is negative. It also sets errno to EDOM.
-
-
-